from django.shortcuts import render
from task.models import SimpleTask

# Create your views here.

# Create your views here.
def refresh(request):
    info = {}

    info['refer'] = request.META.get('HTTP_REFERER',"/")
    if info['refer'].find("/refreshData/") != -1:
        info['refer'] = "/index/"

    task = SimpleTask.objects.filter(name="refresh_all")
    if task != None and len(task) > 0:
        info['exsit'] = True
        return render(request,"refresh.html", info)

    task = SimpleTask()
    task.name = "refresh_all_quick"
    task.type = 1
    task.argv = ""
    task.lifecycle = 1
    task.save()

    # task = SimpleTask()
    # task.name = "refresh_simple"
    # task.type = 1
    # task.argv = "005765"
    # task.lifecycle = 1
    # task.save()

    return render(request,"refresh.html", info)